package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.enterprise.CompanyListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

public class EpCompanyAdapter extends BaseRecycleAdapter<CompanyListEntity> {
    ImageView roundImageView;
    TextView tv_title_hot;
    TextView tv_price_hot;
    TextView tv_time_hot;
    private Context context;

    public EpCompanyAdapter(Context context, List<CompanyListEntity> datas) {
        super(context, R.layout.item_enterprise_remenjiaoyi, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, CompanyListEntity companyListEntity) {
        holder.setBinding(BR.viewModel, companyListEntity);
        roundImageView = holder.getItem().findViewById(R.id.logo_view);
        tv_title_hot = holder.getItem().findViewById(R.id.title_view);
        tv_price_hot = holder.getItem().findViewById(R.id.price_view);
        tv_time_hot = holder.getItem().findViewById(R.id.tv_time);
        if (companyListEntity != null) {
            if (companyListEntity.getLogo() != null && !companyListEntity.getLogo().equals("")) {
            Glide.with(context).load(companyListEntity.getLogo()).into(roundImageView);
            } else {
                roundImageView.setImageResource(R.drawable.null_img_list);
            }
            tv_title_hot.setText(companyListEntity.getTransCompanyName());
            tv_price_hot.setText(companyListEntity.getSalePrice() + "");
            tv_time_hot.setText(DateUtils.timestampTo13Date3(companyListEntity.getUpdateTime()));
        }
    }
}
